# this is a cluster extent index based on distance method
# 
# Author: guochun
###############################################################################

clusterEstimator=function(samples,lambda,samples2=NULL,method="clark"){
	if(method == "clark"){
		d=mean(samples,na.rm=T)
		dreal=1/2/sqrt(lambda)
		return(d/dreal)
	}else if(method == "hopkin"){
		samples=samples[!is.na(samples) & samples!=Inf ]
		samples2=samples2[!is.na(samples2) & samples2!= Inf]
		return(sum(samples2^2,na.rm=T)/sum(samples^2,na.rm=T)*length(samples)/length(samples2))
	}else if(method == "my"){
		samples=samples[!is.na(samples) & samples!=Inf ]
		samples2=samples2[!is.na(samples2) & samples2!= Inf]
		re=sum(samples2,na.rm=T)/sum(samples,na.rm=T)*length(samples)/length(samples2)
		return(re)
	}

}

